package com.JZ.QM.controller;

import com.JZ.QM.common.entity.EntrustDetailEntity;
import com.JZ.QM.common.entity.EntrustRecordEntity;
import com.JZ.QM.common.utils.CommonResult;
import com.JZ.QM.service.EntrustRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * @author: cyc
 * @email cyc@gmail.com
 * @date: 2020/7/9 15:07
 */
@RestController
@RefreshScope
@Slf4j
@RequestMapping(value="/entrustRecord")
public class EntrustRecordController {

    @Resource
    EntrustRecordService entrustRecordService;

    /**
     * 通过交易记录id获取委托列表
     * @param tradeId 交易记录id
     * @return
     */
    @RequestMapping("/getEntrustRecordByTradeId")
    public CommonResult entrustRecordByTradeId(Long tradeId){
        //委托列表信息
        ArrayList<EntrustDetailEntity> entrustRecordEntities = new ArrayList<>();

        //获取交易记录对应的组合产品委托信息列表
        entrustRecordEntities=entrustRecordService.getEntrustRecordsByTradeId(tradeId);
        return CommonResult.success().put("entrustList",entrustRecordEntities.toArray());
    }
}
